import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { CommontTypes, ResponseVo, CouponTypes, PlanSchemeTypes, PageResult, PlanSchemeStatusEnum } from '@/type';

export namespace PlanSchemeService {
  export const addPlanScheme = async (data:Partial<PlanSchemeTypes.planSchemeItem>): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/planScheme/add',data,{baseURL: BASE_API});
    return res;
  };

  export const pagePlanScheme = async (data:Partial<PlanSchemeTypes.PlanSchemePage>): Promise<ResponseVo<PageResult<PlanSchemeTypes.PlanSchemeTableData>>> => {
    let res:ResponseVo<PageResult<PlanSchemeTypes.PlanSchemeTableData>> = await axios.get('/planScheme/page',{params:data,baseURL: BASE_API});
    return res;
  };

  export const detailPlanScheme = async (id:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/planScheme/detail',{params:{id},baseURL: BASE_API});
    return res;
  };

  export const updateSchemeStatus = async (id:number,status:PlanSchemeStatusEnum): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/planScheme/updateStatus',{params:{id,status},baseURL: BASE_API});
    return res;
  };

  export const editPlanScheme = async (data:Partial<PlanSchemeTypes.planSchemeItem>): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/planScheme/edit',data,{baseURL: BASE_API});
    return res;
  };
  
}
